package com.leyou.order.client;

import com.leyou.common.utils.JsonUtils;
import com.leyou.order.dto.AddressDTO;

import java.util.ArrayList;
import java.util.List;

public abstract class AddressClient {

    private static final List<AddressDTO> addrList;

    static {
        addrList = new ArrayList<>();
        AddressDTO addrDefault = new AddressDTO();
        addrDefault.setId(1L);
        addrDefault.setName("锋哥");
        addrDefault.setPhone("15800000000");
        addrDefault.setState("上海");
        addrDefault.setCity("上海");
        addrDefault.setDistrict("浦东新区");
        addrDefault.setAddress("航头镇航头路18号传智播客 3号楼");
        addrDefault.setZipCode("210000");
        addrDefault.setDefaultAddr(true);
        addrList.add(addrDefault);

        AddressDTO addrOther = new AddressDTO();
        addrOther.setId(2L);
        addrOther.setName("张三");
        addrOther.setPhone("13600000000");
        addrOther.setState("北京");
        addrOther.setCity("北京");
        addrOther.setDistrict("朝阳区");
        addrOther.setAddress("天堂路 3号楼");
        addrOther.setZipCode("100000");
        addrOther.setDefaultAddr(false);
        addrList.add(addrOther);
    }

    public static AddressDTO queryAddressById(Long id) {
        for (AddressDTO addressDTO : addrList) {
            if (addressDTO.getId().equals(id)) {
                return addressDTO;
            }
        }

        return null;
    }
}
